package com.animations;

import com.beans.BirdBean;
import creator.ui.graphics.Magicanvas;
import creator.ui.graphics.bean.Switch;
import creator.ui.graphics.polaroid.Animation;
import java.awt.Graphics;

public class BirdKeepMoveAction extends Animation {

  public void loadBean() {}

  public void paint(Graphics g) {}

  public synchronized void run() {
    doMove();
  }

  private void doMove() {
    int birdY = BirdBean.getBirdY();
    int highest = birdY - 3;
    int lowest = birdY + 3;
    boolean birdrisAble = true;
    while ((Switch._isContinue()) && (!Tag._isPlay())) {
      if (birdrisAble) BirdBean.setBirdY(birdY--); else BirdBean.setBirdY(
        birdY++
      );
      if (BirdBean.getBirdY() == highest) birdrisAble = false;
      if (BirdBean.getBirdY() == lowest) birdrisAble = true;
      try {
        Thread.sleep(50L);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      getMagicanvas().repaint();
    }
  }
}
